package com.hngy.educationaladministration.controller.convert;

import com.hngy.educationaladministration.entity.CourseTable;
import com.hngy.educationaladministration.entity.co.CourseTableCo;
import com.hngy.educationaladministration.service.ProjectService;
import com.hngy.educationaladministration.service.StudentService;
import com.hngy.educationaladministration.service.TeacherService;
import com.hngy.educationaladministration.utils.ApplicationContextHolder;
import org.springframework.beans.BeanUtils;

/**
 * @Author: Deng JunHao
 * @Date: 2021-05-16
 * @Description:
 */
public class StudentConvert {

    public static CourseTableCo toCo(CourseTable courseTable) {
        CourseTableCo courseTableCo = new CourseTableCo();
        BeanUtils.copyProperties(courseTable, courseTableCo);
        StudentService studentService = ApplicationContextHolder.getBean(StudentService.class);
        TeacherService teacherService = ApplicationContextHolder.getBean(TeacherService.class);
        ProjectService projectService = ApplicationContextHolder.getBean(ProjectService.class);
        courseTableCo.setStudentName(studentService.getStudentInfoBySid(courseTable.getSid()).getName());
        courseTableCo.setTeacherName(teacherService.getTeacherInfoByTid(courseTable.getTid()).getName());
        return courseTableCo;
    }
}

